/**
 * @author		Sergey Suzdalskiy
 * @e-mail:		sergey.suzdalskiy@gmail.com
 */
package ua.kiev.gcore.logger
{
	public class LoggerMessage
	{
		public static const INFO_TYPE:int = 1;
		public static const DEBUG_TYPE:int = 2;
		public static const WARNING_TYPE:int = 3;
		public static const ERROR_TYPE:int = 4;
		
		public static const INFO_NAME:String = "INFO";
		public static const DEBUG_NAME:String = "DEBUG";
		public static const WARNING_NAME:String = "WARNING";
		public static const ERROR_NAME:String = "ERROR";
			
		public var Time:Number;
		public var Level:int;
		public var Type:int;
		public var Message:String;
		
		
		public function LoggerMessage(Message:String, Type:int, Time:Number, Level:int)
		{
			this.Message = Message;
			this.Type = Type;
			this.Level = Level;
			this.Time = Time;
		}
		
		public function getColot():String{
			var result:String;
			switch(Type){
				case INFO_TYPE:
					result = "#0C73E8";
					break;
				case DEBUG_TYPE:
					result = "#000000";
					break;
				case WARNING_TYPE:
					result = "#E8AE0C";
					break;
				case ERROR_TYPE:
					result = "#FF0D0D";
					break;
			}
			return result;
		}
		
		public function getFormatedMessage():String{
			var result:String = getFormatedTitel();
			result +=  " " + Message;
			return result;
		}
		
		public function getFormatedMessageHTML():String{			
			var result:String = "<font color='" + getColot() + "'><b> " + getFormatedTitel() + ": </b> " + Message + "</font>";
			
			return result;
		}
		
		public function getFormatedTitel():String{
			var result:String = new String();
			
			result = "[" + Time.toString() + "] ";
			switch(Type){
				case INFO_TYPE:
					result += INFO_NAME;
					break;
				case DEBUG_TYPE:
					result += DEBUG_NAME;
					break;
				case WARNING_TYPE:
					result += WARNING_NAME;
					break;
				case ERROR_TYPE:
					result += ERROR_NAME;
					break;
				
			}
			
			return result;
		}
	}
}